package command;

import java.util.Arrays;

public class ClientInvoker {
    private static Command[] commands = new Command[10];
    private static Command undoCommand;

    public ClientInvoker() {
        NoCommand noCommand = new NoCommand();
        Arrays.fill(commands, noCommand);
        undoCommand = noCommand;
    }

    public void setCommand(int slot, Command command) {
        commands[slot] = command;
    }

    public void undo() {
        System.out.print("undo 后恢复到: ");
        undoCommand.undo();
    }

    public void pressButton(int slot) {
        commands[slot].execute();
        undoCommand = commands[slot];
    }
}
